<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String orderNo = request.getParameter("orderNo");
String orderDetailUuid = request.getParameter("orderDetailUuid");
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description" />
<meta content="B2B电商平台" name="keyword" />

<title>B2B电商平台.订单发货</title>
<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/global.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/pro.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/proManage.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css" type="text/css"></link>
<link rel="stylesheet" type="text/css" href="<%=path%>/include/pagination/page.css" media="all">
<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/mmt_trading.css" />
<link rel="stylesheet" type="text/css" href="http://style.org.hc360.com/js/build/source/widgets/wij/hc.wijmo.css" />
<link rel="stylesheet" type="text/css" href="http://style.org.hc360.com/js/build/source/widgets/wij/hc.wijcalendar.css" />
<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script src="<%=path %>/include/wijmo/external/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/external/globalize.min.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/external/cultures/globalize.cultures.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijpopup.js" type="text/javascript"></script>
<script src="<%=path %>/include/wijmo/wijmo/jquery.wijmo.wijcalendar.js" type="text/javascript"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.busin.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path%>/include/pagination/jquery.pagination.js"></script>
<script type="text/javascript" src="<%=path%>/include/pagination/init.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/doT.min.js"></script>
<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>
<script type="text/javascript" src="<%=path%>/include/js/json2.js"></script>
<script src="<%=path%>/include/DatePicker/WdatePicker.js" charset="UTF-8" type="text/javascript"></script>
<link rel="stylesheet"	href="<%=path %>/include/sweetalert/sweetalert.css" type="text/css"></link>
<script type="text/javascript"	src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript"	src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>

<style type="text/css">
button {
	    font: 16px "Microsoft YaHei", "SimHei ";
	    line-height: 30px;
	    width: 60px;
	    background: url('<%=path %>/images/postTrade/pic-global.png') no-repeat -150px -578px;
	    color: #fff;
	}
</style>

<script type="text/javascript">
	$(document).ready(function() {
		$("input[name='deliverType'][value='${orderInfo.MAIL_TYPE}']").attr("checked",'checked'); 
		if('${orderInfo.MAIL_TYPE}' == '2'){
			$("#deliverDivTitle").hide();
		} else {
			$("#deliverDivTitle").show();
		}
		$('input:radio[name="deliverType"]').change(function(){ 
			var deliverType=$('input:radio[name="deliverType"]:checked').val();
			if(deliverType == '2'){
				$("#deliverDivTitle").hide();
			} else {
				$("#deliverDivTitle").show();
			}
		});
	});
	
	//验证是否选择车辆或者是否填写订单编号
	function _checkReason(){
		var deliverType=$('input:radio[name="deliverType"]:checked').val();
		if(deliverType == '1'){
			var b = /^[a-zA-Z0-9]*$/;
			var orderCode = $("#orderCode").val();
			if(orderCode == '' || orderCode == 'undefined'){
				parent.layer.alert('请输入快递单号!',{
					offset: '150px'
				});
				return false;
			}
			if(!b.test(orderCode)){
				parent.layer.alert('快递单号只包含字母数字',{
					offset: '150px'
				});
				return false;
			}
		}
		return true;
	 }
	
	/**
	*发货
	*/
	function _shipOrderGoods(){
		if( _checkReason()){
			$("#shipOrderGoods").attr("disabled", true); 
			$("#shipOrderGoods").addClass("Disabled");
			var deliverType=$('input:radio[name="deliverType"]:checked').val();
			var orderCode = $("#orderCode").val();
			var flag = $("#flag").val();
			var orderNo = $("#orderNo").val();
			var orderUuid = $("#orderUuid").val();
			var orderStatus = $("#orderStatus").val();
			var orderUuids = $("#orderUuids").val();
			var url = "<%=path%>/orderList/shipOrder.do";
			var infoMsg = "发货失败!";
			if(flag=="batch"){
				url = "<%=path%>/orderList/operateBatch.do";
				infoMsg = "批量发货失败!";
			}
			
			$.ajax({
		 		type:"GET",
				url:url,
				data: {
					orderNo : orderNo,
					orderUuid : orderUuid,
					orderStatus : orderStatus,
					orderUuids : orderUuids,
					deliverType : deliverType,
					orderCode : orderCode
					//carOrDeliverUuid : carOrDeliverUuid,
					//shipperCode : shipperCode,
					//payType : payType,
					//ifRes : ifRes
				},
				dataType:"json",
				async : false, //同步执行
				success:function(data){
					if(data.success){
							if(data.msg=="物流单号为空")
								parent.layer.alert('快递单号不存在,请重新输入快递单号',{
									offset: '150px'
								});
							else _closeIframe();
					} else {
						parent.swal("OMG",infoMsg, "error");
						_closeIframe();
					}
				},error:function(data){
					$("#shipOrderGoods").attr("disabled", false); 
					$("#shipOrderGoods").removeClass("disabled");
				}
		 	});
		}
	}
	//关闭 弹出层
   	function _closeIframe(){
   		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
		parent.layer.close(index);
   	}

   	function _checkRadio(val,val1){
   	   	$(".dyn").css("display",val);
   	   	$(".dy").css("display",val1);
   	}
</script>
</head>

<body style="font-family: '微软雅黑'">
	<div style="margin-top:0px;padding:20px;width:auto;height:120px;border: none;">
		<input type="hidden" name ="orderUuid" id= "orderUuid" value="${orderUuid}"/>
		<input type="hidden" name ="orderNo" id= "orderNo" value="${orderNo}"/>
		<input type="hidden" name ="orderStatus" id= "orderStatus" value="${orderStatus}"/>
		<input type="hidden" name ="orderUuids" id= "orderUuids" value="${orderUuids}"/>
		<input type="hidden" name ="flag" id= "flag" value="${flag}"/>
		<div style="margin-top:0px;width:100%;border: none;height:30px;overflow:hidden;">
			<div style="width:30%;float:left;text-align:right;padding-right:20px;">配送方式： </div>
			<div style="width:60%;float:left;text-align:left;">
				<input type='radio' name='deliverType' value='1'/>快递&nbsp;
				<input type='radio' name='deliverType' value='2'/>EMS&nbsp;
			</div>
			
		</div>
		<div style="margin-top:0px;width:100%;border: none;overflow:hidden;">
			<div id="deliverDivTitle" style="display: ">
				<div class="dy" style="height: 30px;">
					<div style="width:30%;float:left;text-align:right;padding-right:20px;">请输入快递单号：</div>
					<div style="width:60%;float:left;text-align:left;">
						<input type="text" name="orderCode" id="orderCode" style="width: 180px;"/>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div style="margin-top:50px;width:100%;text-align:center;">
		<button id="shipOrderGoods" onclick="_shipOrderGoods();"  >保存</button>
		<button onclick="_closeIframe();">取消</button>
	</div>
</body>
</html>
